package enduringLink.call;

import instance.Main;
import reader.BigFileReader;
import reader.PartAndLineItemHandler;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

//开始加载对象，用于在RPC调用中传递开始加载的信息
public class MyStartLoad implements StartLoad{
    private static int instanceId;
    @Override
    public void begin() {
        System.out.println("开始加载......");
        int fileReaderThreadNum = 0;
        try {
            InputStream is = PartAndLineItemHandler.class.getClassLoader().getResourceAsStream("address.properties");
            Properties properties = new Properties();
            properties.load(is);
            fileReaderThreadNum = Integer.parseInt(properties.getProperty("fileReaderThreadNum"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        File file1 = new File(Main.path1);
        File file2 = new File(Main.path2);
        BigFileReader reader = new BigFileReader(file1, file2, fileReaderThreadNum, 0, 1, instanceId);
        reader.start();//正式开始加载数据
    }

    public MyStartLoad(int id){
        instanceId = id;
    }
    public MyStartLoad(){

    }

}
